﻿using System;

namespace MessagePack.Formatters
{
	// Token: 0x02000041 RID: 65
	public class NullableSingleFormatter : IMessagePackFormatter<float?>
	{
		// Token: 0x060000F3 RID: 243 RVA: 0x0000469C File Offset: 0x00002A9C
		private NullableSingleFormatter()
		{
		}

		// Token: 0x060000F4 RID: 244 RVA: 0x000046A4 File Offset: 0x00002AA4
		public int Serialize(ref byte[] bytes, int offset, float? value, IFormatterResolver formatterResolver)
		{
			if (value == null)
			{
				return MessagePackBinary.WriteNil(ref bytes, offset);
			}
			return MessagePackBinary.WriteSingle(ref bytes, offset, value.Value);
		}

		// Token: 0x060000F5 RID: 245 RVA: 0x000046CC File Offset: 0x00002ACC
		public float? Deserialize(byte[] bytes, int offset, IFormatterResolver formatterResolver, out int readSize)
		{
			if (MessagePackBinary.IsNil(bytes, offset))
			{
				readSize = 1;
				return null;
			}
			return new float?(MessagePackBinary.ReadSingle(bytes, offset, out readSize));
		}

		// Token: 0x04000035 RID: 53
		public static readonly NullableSingleFormatter Instance = new NullableSingleFormatter();
	}
}
